home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / gus / patinf11.zip / PATINFO.BAS < prev    next >
BASIC Source File  |  1993-03-25  |  6KB  |  248 lines

  1. 'PATINFO  V1.1  by Joseph Maruschek  aa344@yfn.ysu.edu
  2. 'This program shows you some of the information kept in the
  3. 'headers of the GUS's patch files.  I don't have the SDK, so
  4. 'some of the information in the header is still unknown.  I don't
  5. 'entirely understand the format of the detune field, but I include
  6. 'it's value in the display.  There is also amplitude envelope
  7. 'data that I don't yet understand, but I display it anyway.
  8. 'Feel free to write to me at the above address if you have any
  9. 'questions or comments.
  10.  
  11. 'The author cannot be held responsible for damage to your files
  12. 'or computer due to mis-use of this code.
  13.  
  14.  
  15. dim shared notes(12)
  16. dim shared names$(12)
  17. for i=1 to 12
  18.   read y
  19.   notes(i)=y
  20.   read y$
  21.   names$(i)=y$
  22. next i
  23.  
  24. data 16.35,"C",17.32,"C#",18.35,"D",19.45,"D#",20.6,"E",21.83,"F"
  25. data 23.12,"F#",24.5,"G",25.96,"G#",27.5,"A",29.14,"A#",30.87,"B"
  26.  
  27.  
  28. '***************************SUBROUTINES***************************
  29. sub Readfour(x,blck,t1$,t2$,offs) static
  30.  
  31. if offs-blck*128+1 <=128 then
  32.   x=asc(mid$(t1$,offs-blck*128+1,1))
  33. else
  34.   x=asc(mid$(t2$,offs-(blck+1)*128+1,1))
  35. end if
  36. if offs-blck*128+2 <=128 then
  37.   x=x+ 256.0*asc(mid$(t1$,offs-blck*128+2,1))
  38. else
  39.   x=x+ 256.0*asc(mid$(t2$,offs-(blck+1)*128+2,1))
  40. end if
  41. if offs-blck*128+3 <=128 then
  42.   x=x + 65536.0*asc(mid$(t1$,offs-blck*128+3,1))
  43. else
  44.   x=x + 65536.0*asc(mid$(t2$,offs-(blck+1)*128+3,1))
  45. end if
  46. if offs-blck*128+4 <=128 then
  47.   x=x+ 16777216.0*asc(mid$(t1$,offs-blck*128+4,1))
  48. else
  49.   x=x+ 16777216.0*asc(mid$(t2$,offs-(blck+1)*128+4,1))
  50. end if
  51.  
  52. end sub
  53.  
  54. sub Readtwo(x,blck,t1$,t2$,offs) static
  55.  
  56. if offs-blck*128+1 <=128 then
  57.   x=asc(mid$(t1$,offs-blck*128+1,1))
  58. else
  59.   x=asc(mid$(t2$,offs-(blck+1)*128+1,1))
  60. end if
  61. if offs-blck*128+2 <=128 then
  62.   x=x+ 256.0*asc(mid$(t1$,offs-blck*128+2,1))
  63. else
  64.   x=x+ 256.0*asc(mid$(t2$,offs-(blck+1)*128+2,1))
  65. end if
  66.  
  67. end sub
  68.  
  69.  
  70. sub Readone(x,blck,t1$,t2$,offs) static
  71.  
  72. if offs-blck*128+1 <=128 then
  73.   x=asc(mid$(t1$,offs-blck*128+1,1))
  74. else
  75.   x=asc(mid$(t2$,offs-(blck+1)*128+1,1))
  76. end if
  77.  
  78. end sub
  79.  
  80.  
  81. sub Notename(x,name$) static
  82.  
  83. name$=""
  84. if x=0 then
  85.   name$="None"
  86. else
  87.   octave=0
  88.   i =1
  89.   loop1:
  90.   if abs(x-(notes(i)*2^(octave))) <1 then goto loopend
  91.   if notes(i)*2^(octave) > x then
  92.     name$="?"
  93.     if abs(x-notes(i-1)*2^octave) < abs(x-notes(i)*2^octave) then i=i-1
  94.     goto loopend
  95.   end if
  96.   i=i+1
  97.   if i=13 then
  98.     i=1
  99.     octave=octave+1
  100.   end if
  101.   goto loop1
  102.  
  103.   loopend:
  104.   name$=name$+names$(i)+chr$(48+octave)
  105. end if
  106. end sub
  107.  
  108. '*********************************MAIN PROGRAM************************
  109. if Command$="" then goto help
  110. on error goto handle
  111. open Command$ for input as #1
  112. close 1
  113. open Command$ as #1
  114. field 1, 128 as v$
  115.  
  116. get 1
  117. if left$(v$,8)="GF1PATCH" then
  118.   print "File: "Command$
  119. else
  120.   print left$(v$,8)
  121.   print "Not a patch file."
  122.   goto fin
  123. end if
  124.  
  125.  
  126. numsamps=asc(mid$(v$,86,1))
  127. print "This file contains "numsamps" sample(s)."
  128.  
  129. offset=0
  130. noff=239
  131.  
  132. for i=1 to numsamps
  133.  
  134.   print
  135.   print "Sample #"i
  136.  
  137.   offset=offset+noff
  138.   block=fix(offset/128.0)
  139.   sampbegin=offset+96
  140.  
  141.   get 1,block+1
  142.   temp1$=v$
  143.   get 1,block+2
  144.   temp2$=v$
  145.  
  146.   offset=offset+7
  147.   call Readone(v,block,temp1$,temp2$,offset)
  148.   mode=v
  149.  
  150.   offset=offset+1
  151.   call Readfour(v,block,temp1$,temp2$,offset)
  152.   print "Sample length:"v,
  153.   noff=v
  154.  
  155.   offset=offset+4
  156.   call Readfour(v,block,temp1$,temp2$,offset)
  157.   print "Loop start: "v,
  158.  
  159.   offset=offset+4
  160.   call Readfour(v,block,temp1$,temp2$,offset)
  161.   print "Loop end:"v
  162.  
  163.   offset=offset+4
  164.   call Readtwo(v,block,temp1$,temp2$,offset)
  165.   print "Sample rate:"v"Hz"
  166.  
  167.   offset=offset+2
  168.   call Readfour(v,block,temp1$,temp2$,offset)
  169.   call Notename(v/1000,n$)
  170.   print "Low freq:";v/1000;"("n$")    ";
  171.  
  172.   offset=offset+4
  173.   call Readfour(v,block,temp1$,temp2$,offset)
  174.   call Notename(v/1000,n$)
  175.   print "High freq:";v/1000;"("n$")    ";
  176.  
  177.   offset=offset+4
  178.   call Readfour(v,block,temp1$,temp2$,offset)
  179.   call Notename(v/1000,n$)
  180.   print "Base freq:";v/1000;"("n$")"
  181.  
  182.   offset=offset+4
  183.   call Readone(v,block,temp1$,temp2$,offset)
  184.   if v>128 then v=v-256
  185.   print "Detune:"v,
  186.  
  187.   offset=offset+1
  188.   call Readone(v,block,temp1$,temp2$,offset)
  189.   print "Octave:"v,
  190.  
  191.   offset=offset+1
  192.   call Readone(v,block,temp1$,temp2$,offset)
  193.   print "Balance:"v,
  194.   print "Mode:";
  195.   for j=8 to 1 step -1
  196.     if (mode and 2^(j-1)) then print " 1"; else print " 0";
  197.   next j
  198.   print
  199.   print "Envelope/tremolo/vibrato data:"
  200.   for j=1 to 18
  201.     offset=offset+1
  202.     call Readone(v,block,temp1$,temp2$,offset)
  203.     print using " ###";v;
  204.   next j
  205.   print
  206.   offset=offset+1
  207.   call Readone(v,block,temp1$,temp2$,offset)
  208.   print "Flags: ";
  209.   if (v and 1) then print "16-bit "; else print "8-bit ";
  210.   if (v and 4) then print "looped "; else print "no-loop ";
  211.   if (v and 16) then print "reverse "; else print "forward ";
  212.   if (v and 32) then print "melodic ": else print "percussive ";
  213.   print
  214.   offset=sampbegin
  215. next i
  216.  
  217. fin:
  218. close 1
  219. end
  220.  
  221. handle:
  222. if err=53 then
  223.   print "File not found."
  224.   goto fin
  225. else
  226.   if err=64 then
  227.     print "Bad file name.  Don't use wildcards."
  228.     goto fin
  229.   else
  230.     if err=52 then
  231.       print "Bad file number.  Can only view one file at a time."
  232.       goto fin
  233.     else
  234.       print "Error number:"err
  235.       goto fin
  236.     end if
  237.   end if
  238. end if
  239. resume
  240.  
  241. help:
  242. print
  243. print "PATINFO  V1.0  by Joseph Maruschek"
  244. print "Shows information contained in a patch file."
  245. print
  246. print "Usage:  PATINFO filename"
  247. goto fin
  248.